﻿# include"AStar.h"
# include"AStar2.h"
# include"AStar3.h"
# include"Dijkstra.h"
# include<iostream>
# include<ctime>

using namespace std;


clock_t start;
clock_t end;
double itime ;
struct node
{
	int x,y;
};
vector<node> data;


void auto_test_a1()
{
	double Atime1 = 0.0;
	AStarEngine *aTest = new AStarEngine();
	vector<node>::iterator iter;
	for (iter = data.begin() ;iter != data.end() ;iter ++)
	{
		int x = iter->x ;
		int y = iter->y;
		start = clock();
		aTest->Solve(x,y);
		end = clock();
		Atime1 += (double)(end-start)/CLOCKS_PER_SEC ;
	}
	cout << "A* : " << Atime1<< endl ;

}
void auto_test_a2()
{
	double Atime2 = 0.0;
	AStarEngine2 *aTest2 = new AStarEngine2();
	vector<node>::iterator iter;
	for (iter = data.begin() ;iter != data.end() ;iter ++)
	{
		int x = iter->x ;
		int y = iter->y;

		start = clock();
		aTest2->Solve(x,y);
		end = clock();
		Atime2 += (double)(end-start)/CLOCKS_PER_SEC ;
	}
	cout << "A2* : " << Atime2<< endl ;

}

void auto_test_a3()
{
	double Atime3 = 0.0;
	AStarEngine3 * aTest3 = new AStarEngine3();
	vector<node>::iterator iter;
	for (iter = data.begin() ;iter != data.end() ;iter ++)
	{
		int x = iter->x ;
		int y = iter->y;

		start = clock();
		aTest3->Solve(x,y);
		end = clock();
		Atime3 += (double)(end-start)/CLOCKS_PER_SEC ;
	}
	cout << "A3* : " << Atime3<< endl ;

}

void auto_test_dij()
{
	double Dtime = 0.0;
	DijkstraEngine *dTest = new DijkstraEngine();
	vector<node>::iterator iter;
	for (iter = data.begin() ;iter != data.end() ;iter ++)
	{
		int x = iter->x ;
		int y = iter->y;
		start = clock();
		dTest->Solve(x,y);
		end = clock();
		Dtime +=(double)(end-start)/CLOCKS_PER_SEC ;
		
	}
	cout << "Dijstra : " << Dtime <<endl;

}

void auto_test_main()
{
	freopen("in.txt","r",stdin);
	int s ,e;
	while(scanf("%d%d",&s,&e) != EOF)
	{
		if(s == 0 || e==0)
			break;
		node temp ;
		temp.x = s;
		temp.y = e;
		data.push_back(temp);
	}	
}

void debug_test_a2()
{
	int s,e;
	double Atime2 = 0.0;
	AStarEngine2 *aTest2 = new AStarEngine2();
	while(scanf("%d%d",&s,&e) != EOF)
	{
		if(s == 0 || e==0)
			break;
		start = clock();
		aTest2->Solve(s,e);
		end = clock();
		Atime2 += (double)(end-start)/CLOCKS_PER_SEC ;
	}
	cout << "A2* : " << Atime2<< endl ;
}
void debug_test_dij()
{
	
	int s,e;
	double DijTime = 0.0;
	DijkstraEngine *dTest = new DijkstraEngine();
	while(scanf("%d%d",&s,&e) != EOF)
	{
		if(s == 0 || e==0)
			break;
		start = clock();
		dTest->Solve(s,e);
		end = clock();
		DijTime += (double)(end-start)/CLOCKS_PER_SEC ;
	}
	cout << "Dij* : " <<  DijTime<< endl ;
}
void  debug_test_main()
{
	//freopen("in.txt","r",stdin);
	cout << "please  enter data" << endl; 
	debug_test_a2();
	//debug_test_dij();
}


void test_main()
{	
	//freopen("in.txt","r",stdin);	//freopen("out.txt","w",stdout);	
	int s,e;

	//cout << "data had read" << endl;
	double Atime2 = 0.0;
	AStarEngine2 *aTest2 = new AStarEngine2();

	start = clock();
	/*s = 62232;
	e = 59200;*/
	//s = 22792;
	//e = 23291;
	s = 24239;
	e = 24234;
	for(int i=0;i<10000;i++)
	{
		aTest2->Solve(s,e);
	}

	end = clock();
	Atime2 += (double)(end-start)/CLOCKS_PER_SEC ;
	cout << "A2* : " << Atime2<< endl ;


}

int main()
{

	
	//
	freopen("out.txt","w",stdout);

	//debug_test_main();
	
	test_main();

	
	return 0;
}